/** @file Client.h
* @class Client
* @brief Handles all the connected players and their actions
* 
*/
#include "stdafx.h"

#ifndef _Client_h_
#define _Client_h_

#include "MessageIdentifiers.h"
#include "RakPeerInterface.h"

#include "RakNetTypes.h"
#include "BitStream.h"
#include "Command.h"
#include "MoveCommand.h"
#include "ViewCommand.h"
#include "SpawnCommand.h"
#include <Windows.h>	

#include <string>
#include <iostream>

class Client {
	private:
		GameObject* myGameObject;
		char* serverPort;
		char* serverPassword;

		char *maxPlayers;
		char *ip;

		RakNet::MessageID type;
		RakNet::RakString rs;
		RakNet::BitStream bsOut;
		SpawnCommand *c;
		Model *model;
	public:
		RakNet::RakPeerInterface *client;
		RakNet::Packet *packet;
		RakNet::SystemAddress serverAddress;
		bool connected;
		/**
		* @brief syncronizes the position of other clients
		* 
		*/
		void Client::syncc();
		/**
		* @brief creates and startup an client
		* 
		*/
		void createClient(char *maxPlayers, Model *model);
		/**
		* @brief connects to a server
		* 
		*/
		void connect(char* ip, char* port, const char* password);
		/**
		* @brief terminates the client and send out a disconnect command to the server
		* 
		*/
		void disconnect();
		/**
		* @brief receiving all the incoming packets
		* 
		*/
		void receivePackets();
		/**
		* @brief handling incoming commands
		* 
		*/
		void retreiveCommands(RakNet::BitStream &bs);
};

#endif